#!/usr/bin/python3
# -*- coding: UTF-8 -*-


import rospy,time,tf
from nav_msgs.msg import Odometry

class OdomTfPub:
    def __init__(self):
        rospy.init_node("odom_tf_pub")
        self.__odom_sub = rospy.Subscriber("/odom_origin", Odometry, self.OdomCallback)

    def OdomCallback(self, msg):
        br = tf.TransformBroadcaster()
        x = msg.pose.pose.position.x
        y = msg.pose.pose.position.y
        quaternion = (
            msg.pose.pose.orientation.x,
            msg.pose.pose.orientation.y,
            msg.pose.pose.orientation.z,
            msg.pose.pose.orientation.w)
        msg_time = msg.header.stamp
        # msg_time = rospy.Time.now()
        br.sendTransform((x, y, 0), quaternion, msg_time, "base_link", "odom")

if __name__ == "__main__":
    OdomTfPub()
    rospy.spin()